<template>
  <!--  近2周记录-->
  <div class="container-big">
    <div class="formGroup">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px" class="">
        <el-button type="primary" size="small" @click="handerAddTask" v-hasPermi="['SingleCircleFriendsMgt:add']"><i class="el-icon-plus"></i>新建任务</el-button>
        <el-form-item prop="userName2">
          <el-select v-model="queryParams.userName2" filterable placeholder="请选择分组" @change="handleQuery">
            <el-option
              v-for="item in groupList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
            <div class="other-option">
              <a class="link">企业管理</a>
            </div>
          </el-select>
        </el-form-item>
        <el-form-item prop="userName2">
          <div class="search">
          <el-input v-model="queryParams.userName1" placeholder="搜任务" clearable/>
          <el-button icon="el-icon-search" size="small" @click="handleQuery"></el-button>
          </div>
        </el-form-item>
        <el-form-item prop="userName2">
          <el-select v-model="queryParams.userName2" size="small" filterable placeholder="请选中任务状态" @change="handleQuery">
            <el-option
              v-for="item in userList"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="userName3">
          <div class="right-big">
            <span>发布时间：</span>
            <el-date-picker
              v-model="dateRange1"
              value-format="yyyy-MM-dd HH:mm:ss"
              type="datetimerange"
              range-separator="-"
              size="small"
              start-placeholder="开始时间"
              end-placeholder="结束时间"
              @change="handleQuery"
            ></el-date-picker>
          </div>
        </el-form-item>
      </el-form>
    </div>
    <div class="content-big">
      <div class="content-left">
        <ul class="nameList">
          <li>
            <div class="flex flexbetween mb-8 title">
              <div class="name">开发任务</div>
              <div class="status green">已完成</div>
              <el-dropdown class="right-dropdown">
                <span class="el-dropdown-link"><i class="el-icon-more"></i></span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item>复制</el-dropdown-item>
                  <el-dropdown-item>追加评论</el-dropdown-item>
                  <el-dropdown-item>删除任务记录</el-dropdown-item>
                  <el-dropdown-item>修改分组</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
            <div class="flex flexbetween">
              <div class="type">图片+文字</div>
              <div class="time">2024-03-19 13:30</div>
            </div>
            <div class="flex flexbetween userSet">
              <div class="item-li">
                <p>id:<span>123</span></p>
                <p><i class="el-icon-check"></i><span>主账号</span></p>
              </div>
            </div>
          </li>
          <li>
            <div class="flex flexbetween mb-8 title">
              <div class="name">开发任务</div>
              <div class="status red">
                <el-tooltip class="item" effect="dark" content="当前没有满足发表条件的客户朋友圈发送失败" placement="top-start">
                  <i class="el-icon-warning-outline"></i>
                </el-tooltip>
                执行失败</div>
              <el-dropdown class="right-dropdown">
                <span class="el-dropdown-link"><i class="el-icon-more"></i></span>
                <el-dropdown-menu slot="dropdown">
                  <el-dropdown-item>复制</el-dropdown-item>
                  <el-dropdown-item>追加评论</el-dropdown-item>
                  <el-dropdown-item>删除任务记录</el-dropdown-item>
                  <el-dropdown-item disabled>修改分组</el-dropdown-item>
                </el-dropdown-menu>
              </el-dropdown>
            </div>
            <div class="flex flexbetween">
              <div class="type">图片+文字</div>
              <div class="time">2024-03-19 13:30</div>
            </div>
            <div class="flex flexbetween userSet">
              <div class="item-li">
                <p>id:<span>123</span></p>
                <p><i class="el-icon-check"></i><span>追评</span></p>
                <p><i class="el-icon-check"></i><span>定时删</span></p>
              </div>
              <div class="name-name">企微号1</div>
            </div>
          </li>
        </ul>
      </div>

      <div class="content-right">
        <!--    查看详情-->
        <viewDetail></viewDetail>
      </div>
    </div>
    <deduplication v-if="showDeduplication" :visableIf.sync="showDeduplication"></deduplication>
  </div>
</template>

<script>
import {listUser, delUser,} from "@/api/system/user";

export default {
  name: "lastWeekList",
  components: {
    'viewDetail': () => import('./viewDetail.vue'),//从客户添加
    'deduplication': () => import('./deduplication.vue'),//去重
  },
  data() {
    return {
      showDeduplication: false,
      groupList: [
        {
          value: '0',
          label: '志新'
        }, {
          value: '1',
          label: '锐行'
        }
      ],
      userList: [
        {
          value: '0',
          label: '志新'
        }, {
          value: '1',
          label: '锐行'
        }
      ],
      taskStatusList: [
        {
          value: '1',
          label: '已完成'
        }, {
          value: '1',
          label: '未完成'
        }
      ],
      showAddBlackByUser: false,//按客户添加
      showAddEnterpriseBlack: false,//企业自动添加
      showSetClearBlack: false,//应用
      showSetChatBlack: false,//
      active: 0,
      visible: false,
      dateRange1: [],//添加时间
      dateRange2: [],//触发时间
      dialogType: 'add',
      showExportPage: false,//导出
      tableHeight: 600,
      tableDataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        userName2: null,
        pageSize: 10,
        id: null,//用户id
        userName1: null,

      },
      total: 8, // 表格的总条数
    };
  },
  created() {
    // this.getList();
    this.tableDataList = [];
    for (let i = 0; i < 10; i++) {
      let obj = {
        name: '小红',
        label1: '18207418337',
        label2: '18207418337',
        label3: '18207418337',
        label4: '18207418337',
      }
      this.tableDataList.push(obj);
    }
  },
  methods: {
    handerSet() {
      console.log('点击数据');
      this.showDeduplication = true;
    },
    handerClear() {
      console.log('点击');
      this.showSetClearBlack = true;
    },
    handerAddTask() {
      this.$router.push({path: '/customerOperationsMgt/circleFriendsMgt/addOrEditCirleFriend'})
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.deptId = undefined;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(val) {
      this.multipleSelection = [];
      if (val && val.length > 0) {
        val.forEach((item) => {
          this.multipleSelection.push(item.id);
        })
        console.log('multipleSelection', this.multipleSelection);
      }
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      //删除
      // const userIds = row.userId || this.ids;
      // this.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项？').then(function () {
      //   return delUser(userIds);
      // }).then(() => {
      //   this.getList();
      //   this.$modal.msgSuccess("删除成功");
      // }).catch(() => {
      // });
      this.$msgBox.showMsgBox({
        title: "是否确认删除？",
        content: "该企微号正在执行服务，删除将会使该号从操作中释放，导致部分功能无法正常使用，请谨慎选择。*如该号已加入在线聊天，成功删除后，聊天记录会被一并删除，重新登录后无法恢复。",
      })
        .then(async (val) => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    handleNumberDelete() {
      this.$modal.confirm('确认清空本页黑名单？').then(function () {
        return delUser(userIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });

    },

  }
};
</script>
<style lang="scss" scoped>
.tooltipContent {
  .h5 {
    font-size: 12px;
  }

  .list-big {
    display: flex;
    flex-wrap: wrap;

    span {
      height: 25px;
      display: flex;
      padding: 0px 5px;
      margin: 4px 4px 4px 0;
      color: rgba(0, 0, 0, .65);
      border: 1px dashed #eee;
    }
  }
}

.keywordList {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;

  .tips {
    color: #2d8cf0;
  }
}

.head-big {
  display: flex;
  justify-content: space-between;
  padding: 20px;
  padding-bottom: 0px;
}

.container-big {
  display: flex;
  height: calc(100vh - 100px);
  margin: 12px;
  flex-direction: column;
  background: #fff;
}

.formGroup {
  width: 100%;
  padding: 10px 20px;
  margin-bottom: 10px;


  .el-form {
    background: #fff;
    border-radius: 8px;
    margin-top: -1px;

    .el-button {
      margin-right: 10px;
    }

    .el-form-item {
      margin-bottom: 0px;

      ::v-deep .el-form-item__content {
        display: flex;

        .el-input {
          width: 150px;
        }
      }

      .right-big {
        border-radius: 4px;
        border: 1px solid #DCDFE6;
        padding-left: 11px;
        height: 32px;
        line-height: 32px;
        overflow: hidden;

        > span {
          color: #777;
          width: 89px;
          display: inline-block;
          white-space: nowrap;
        }

        .el-select {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        .el-input {
          width: 138px;

          ::v-deep .el-input__inner {
            border: none;
          }
        }

        ::v-deep .el-date-editor {
          border: none;
        }
      }

    }
  }
}

.content-big {
  display: flex;
  justify-content: center;
  height: calc(100% - 70px);
  width: 100%;
  border-top: 1px solid #eee;

  .content-left {
    width: 442px;
    padding: 10px;
    background: #eee;
    box-sizing: content-box;


  }

  .content-right {
    flex: 1;
    background: #fff;
  }
}


.nameList {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  font-size: 12px;
  width: 438px;

  li {
    width: 100%;
    display: block;
    padding: 12px 12px 0;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e9e9e9;
    cursor: pointer;
    color: rgba(0, 0, 0, .45);
    position: relative;

    .title {
      padding-right: 20px;

      .right-dropdown {
        position: absolute;
        right: 5px;
        top: 15px;
      }
    }

    .name {
      color: #000;
      font-size: 14px;
    }

    .item-li {
      display: flex;
      align-items: center;
      justify-items: center;

      p {
        margin-right: 10px;
        height: 30px;
        display: flex;
        justify-items: center;
        align-items: center;
        i {
          font-size: 16px;
        }
      }

    }

    .userSet {
      height: 30px;
      border-top: 1px solid #eee;
      margin: 0px -15px;
      padding: 0px 15px;
      margin-top: 15px;
    }

    .el-icon-more {
      position: absolute;
      right: 5px;
      color: #999;
      top: 0px;
      cursor: pointer;

    }

  }
}

.popover-big {
  .popover-title {
    i {
      font-size: 16px;
      color: #f8ac59;
      margin-right: 10px;
    }
  }

  .popover-btn {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
  }
}

.head-right {
  .el-dropdown {
    margin-right: 10px;
  }

  .el-button {
    i {
      margin-right: 5px;
    }
  }
}

.other-option {
  height: 30px;
  display: flex;
  align-items: center;
  color: #2d8cf0;
  font-size: 14px;
  margin-left: 15px;
  border-top: 1px solid #eee;
}

.status {
  font-size: 14px;
  &.green {
    color: #1ab394;
  }
  &.red {
    color:rgb(251, 88, 78);
  }
}
.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}
</style>
